
n = 3


var generateParenthesis = function(n) {
         if(n===0)
         {
            return []
         }
        const res=[]
        function backtrack(current,open,close)
        {
              if(current.length===n*2)
              {
                  res.push(current)
                  return
              }
             if(open<n)
             {
                backtrack(current+"(",open+1,close)
             }
             if(open>close)
             {   
                backtrack(current+")",open,close+1)
             }
        }
        backtrack("(",1,0)
        return res
    
};
console.log(generateParenthesis(n));
